import unittest
from alg import Solution
from gen import generate_test_cases


class TestGenerateParenthesis(unittest.TestCase):
    def setUp(self):
        self.solution = Solution()

    def test_all_cases(self):
        test_cases = generate_test_cases()
        for case in test_cases:
            n = case["n"]
            expected = case["expected"]
            with self.subTest(n=n, expected=expected):
                # 排序结果以便比较（因为生成顺序可能不同）
                actual = self.solution.generateParenthesis(n)
                self.assertEqual(sorted(actual), sorted(expected))


if __name__ == "__main__":
    unittest.main()